<template>
	<view>
		<view class="page-foot bg-white" v-if="!house_id">
			<view class="ptb10 m-hairline--top" @click="submit()">
				<view class="g-btn3 mlrauto">提交审核</view>
			</view>
		</view>
		<uni-forms ref="form" :modelValue="current" :rules="rules" validate-trigger="bind" err-show-type="undertext">

			<view class="container">
				<view class="upload-box" @click="upload(1)">
					<image class="img" v-if="current.build_image" :src="current.build_image" mode="aspectFill"></image>
					<image class="icon-upload" v-else src="/static/icon/icon_upload1.png" mode="aspectFit">
					</image>

				</view>
				<view class="plr30">

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">楼盘名称</view>
						<input type="text" v-model="current.name" class="heading" placeholder="请填写" />
					</view>
					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">楼号</view>
						<input type="text" v-model="current.alias_name" class="heading" placeholder="请填写" />
					</view>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">缩略图</view>
						<view class="upload flex-box flex-wrap flex-align-start">

							<view class="item" @click="upload(2)">
								<image class="img" v-if="current.image" :src="current.image" mode="aspectFit"></image>
								<template v-else>
									<image class="icon"   src="/static/icon/icon_upload1.png"  mode="aspectFit"></image>
									<view class="fs24 cola tc">上传缩略图照片</view>
								</template>
							</view>
						</view>
					</view>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">多图</view>
						<view class="upload flex-box flex-wrap flex-align-start">
							<view class="item" v-for="(item,index) in images">
								<image class="img" :src="item" mode="aspectFill"></image>
								<image class="icon-clear" @click="delImg(index)" src="/static/icon/icon_clear.png"
									mode="aspectFit"></image>
							</view>
							<view class="item btn" @click="upload(3)">
								<image class="icon" src="/static/icon/icon_upload1.png" mode="aspectFit"></image>
								<view class="fs24 cola tc">上传多图照片</view>
							</view>
						</view>
					</view>

					<view class="pb30">
						<view class="fs30 col89 mb30">售卖情况</view>
						<view class="label-list flex-box flex-wrap">
							<block v-for="(item,index) in cus.sale_state">
								<view class="label" @click="checkFmtType(index,'sale_state')" :class="index==cus.sale_state_index?'active':''" style="padding: 0 20rpx;width: unset;">
									{{item.name}}
									<image class="icon-select" src="/static/icon/icon_gou.png" mode="aspectFit"></image>
								</view>
							</block>
						</view>
					</view>
					<view class="pb30">
						<view class="fs30 col89 mb30">低价保障</view>
						<view class="label-list flex-box flex-wrap">
							<block v-for="(item,index) in cus.is_low_price_protect">
								<view class="label" @click="checkFmtType(index,'is_low_price_protect')" :class="index==cus.is_low_price_protect_index?'active':''" style="padding: 0 20rpx;width: unset;">
									{{item.name}}
									<image class="icon-select" src="/static/icon/icon_gou.png" mode="aspectFit"></image>
								</view>
							</block>
						</view>
					</view>




					<view class="pb30">
						<view class="fs30 col89 mb30">楼盘类型</view>
						<view class="label-list flex-box flex-wrap">
							<block v-for="(item,index) in houseType">
								<view class="label" @click="checkType(index)" :class="index==houseTypeIndex?'active':''" style="padding: 0 20rpx;width: unset;">
									{{item.name}}
									<image class="icon-select" src="/static/icon/icon_gou.png" mode="aspectFit"></image>
								</view>
							</block>
						</view>
					</view>

					<view class="pb30">
						<view class="fs30 col89 mb30">开发商品牌</view>
						<view class="label-list flex-box flex-wrap">
							<block v-for="(item,index) in houseDeveloper">
								<view class="label" @click="checkDeveloperType(index)" :class="index==houseDeveloperIndex?'active':''" style="padding: 0 20rpx;width: unset;">
									{{item.name}}
									<image class="icon-select" src="/static/icon/icon_gou.png" mode="aspectFit"></image>
								</view>
							</block>
						</view>
					</view>

					<view class="pb30">
						<view class="fs30 col89 mb30">标签</view>
						<view class="label-list flex-box flex-wrap">
							<block v-for="(v,s_index) in houseHouseTag" :key="s_index">
								<view class="label" :class="v.is_check==true?'active':''"
									@click="chooseTag(s_index)">
									{{v.name}}
									<image class="icon-select" src="/static/icon/icon_gou.png" mode="aspectFit"></image>
								</view>
							</block>


						</view>
					</view>








					<picker mode="date" :value="decorationDate" @change="decorationDatePicker">
						<view class="pb30 mb50 m-hairline--bottom">
							<uni-forms-item name="opentime">
								<input v-model="current.opentime" type="text" hidden></input>
								<view class="fs30 col89 mb30">开盘时间</view>
								<view class="m-arrow-right fs30 col3">
									{{current.opentime.length > 0 ? current.opentime : '请选择'}}
								</view>
							</uni-forms-item>
						</view>
					</picker>

					<picker mode="date" :value="buildDate" @change="buildDatePicker">
						<view class="pb30 mb50 m-hairline--bottom">
							<uni-forms-item name="deliverytime">
								<input v-model="current.deliverytime" type="text" hidden></input>
								<view class="fs30 col89 mb30">交房时间</view>
								<view class="m-arrow-right fs30 col3">
									{{current.deliverytime.length > 0 ? current.deliverytime : '请选择'}}
								</view>
							</uni-forms-item>
						</view>
					</picker>

					<view class="pb30 mb50 m-hairline--bottom">
						<uni-forms-item name="price">
							<view class="fs30 col89 mb30">单价</view>
							<view class="flex-box flex-align-baseline">
								<view class="fs20 col-normal">¥</view>
								<input type="digit"  class="fs40 fwb col-normal" v-model="current.price"
									style="width: 200rpx;" placeholder="0.00" placeholder-class="col-normal" required></input>
								<view class="fs30 col89">元/㎡</view>
							</view>
						</uni-forms-item>
					</view>

					<view class="pb30 mb50 m-hairline--bottom">
						<uni-forms-item name="price">
							<view class="fs30 col89 mb30">最高参考总价</view>
							<view class="flex-box flex-align-baseline">
								<view class="fs20 col-normal">¥</view>
								<input type="digit" class="fs40 fwb col-normal" v-model="current.max_total_price"
									style="width: 200rpx;" placeholder="0.00" placeholder-class="col-normal"></input>
								<view class="fs30 col89">万元</view>
							</view>
						</uni-forms-item>
					</view>

					<view class="pb30 mb50 m-hairline--bottom">
						<uni-forms-item name="price">
							<view class="fs30 col89 mb30">最低参考总价</view>
							<view class="flex-box flex-align-baseline">
								<view class="fs20 col-normal">¥</view>
								<input type="digit" class="fs40 fwb col-normal" v-model="current.min_total_price"
									style="width: 200rpx;" placeholder="0.00" placeholder-class="col-normal"></input>
								<view class="fs30 col89">万元</view>
							</view>
						</uni-forms-item>
					</view>


					<view class="pb30 mb50 m-hairline--bottom flex-box flex-align-start">
						<uni-forms-item name="space">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">建筑面积</view>
								<input type="digit" class="fs30 col10" v-model="current.build_space" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>
						<uni-forms-item name="face">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">厅数</view>
								<input type="text" class="fs30 col10" v-model="current.room_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>
						<uni-forms-item name="floor_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">总楼层数</view>
								<input type="digit" class="fs30 col10" v-model="current.floor_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>

					</view>
					<view class="pb30 mb50 m-hairline--bottom flex-box flex-align-start">

						<uni-forms-item name="room_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">最小几室</view>
								<input type="digit" class="fs30 col10" v-model="current.min_room_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>

						<uni-forms-item name="ting_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">最大几室</view>
								<input type="digit" class="fs30 col10" v-model="current.max_room_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>

						<uni-forms-item name="wei_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">最小面积</view>
								<input type="digit" class="fs30 col10" v-model="current.min_space" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>
					</view>

					<view class="pb30 mb50 m-hairline--bottom flex-box flex-align-start">

						<uni-forms-item name="room_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">最大面积</view>
								<input type="digit" class="fs30 col10" v-model="current.max_space" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>

						<uni-forms-item name="ting_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">电梯</view>
								<input type="digit" class="fs30 col10" v-model="current.elevator_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>

						<uni-forms-item name="wei_num">
							<view class="flex-grow-1">
								<view class="fs30 col89 mb30">步梯</view>
								<input type="digit" class="fs30 col10" v-model="current.stepLadder_num" style="width: 100%;"
									placeholder="请输入" placeholder-class="col10"></input>
							</view>
						</uni-forms-item>
					</view>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">优惠</view>
						<input type="text" v-model="current.discounts" class="heading" placeholder="请填写" />
					</view>
					<view class="pt50 pb30 m-hairline--bottom" v-if="false">
						<view class="fs30 col89 mb25">首付价格信息</view>
						<input type="text" v-model="current.first_price_msg" class="heading" placeholder="请填写" />
					</view>
					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">热门信息</view>
						<input type="text" v-model="current.hot_msg" class="heading" placeholder="请填写" />
					</view>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">VR链接</view>
						<input type="text" v-model="current.vr_url" class="heading" placeholder="请填写" />
					</view>

					<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25 m-arrow-right">省市区</view>
							<view class="fs30 col10" :class="regionName==''?'cola':''">
								{{regionName==''?'请选择':regionName}}
							</view>
						</view>
					</pick-regions>

					<!-- <picker  v-if='regionName' mode="selector" :value="strIdx" :range="street" range-key="name" @change="strChange" v-if="false"> -->
					<picker mode="selector" :value="strIdx" :range="street" range-key="name" @change="strChange" v-if="false">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">街道</view>
							<view class="flex-box">
								<view class="m-arrow-right fs30 col10 flex-grow-1">
									{{current.street|| '请选择'}}
								</view>
							</view>
						</view>
					</picker>
					<view v-if='current.street'  class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">详细地址</view>
						<input class="fs30 col10" v-model="current.addr" placeholder="请输入"></input>
					</view>
					<view class="pt50 pb30 m-hairline--bottom" v-if="false">
						<view class="fs30 col89 mb25">距离地铁（m）</view>
						<input class="fs30 col10" v-model="current.subway_distance" placeholder="请输入"></input>
					</view>
					<view class="pt50 pb30 m-hairline--bottom" v-if="false">
						<view class="fs30 col89 mb25">距离地铁备注</view>
						<input class="fs30 col10" v-model="current.subway_distance_text" placeholder="请输入"></input>
					</view>
					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">咨询热线</view>
						<input class="fs30 col10" v-model="current.cosult_tel" placeholder="请输入"></input>
					</view>


					<view class="pt50 pb30 m-hairline--bottom" v-if="false">
						<view class="fs30 col89 mb25">附近公交站数量</view>
						<input class="fs30 col10" v-model="nearby_bus_num" placeholder="请输入"></input>
					</view>

					<template v-for="(item,index) in nearby_bus_arr">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">公交站{{index+1}}</view>
							<input class="fs30 col10" v-model="item.name" placeholder="请输入位置"></input>
						</view>
					</template>

					<view class="pt50 pb30 m-hairline--bottom" v-if="false">
						<view class="fs30 col89 mb25">附近地铁数量</view>
						<input class="fs30 col10" v-model="nearby_subway_num" placeholder="请输入"></input>
					</view>

					<template v-for="(item,index) in nearby_subway_arr">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">地铁站{{index+1}}</view>
							<input class="fs30 col10" v-model="item.name" placeholder="请输入位置"></input>
						</view>
					</template>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">附近学校数量</view>
						<input class="fs30 col10" v-model="nearby_school_num" placeholder="请输入"></input>
					</view>

					<template v-for="(item,index) in nearby_school_arr">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">学校{{index+1}}</view>
							<input class="fs30 col10" v-model="item.name" placeholder="请输入位置"></input>
						</view>
					</template>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">附近购物数量</view>
						<input class="fs30 col10" v-model="nearby_shop_num" placeholder="请输入"></input>
					</view>

					<template v-for="(item,index) in nearby_shop_arr">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">购物{{index+1}}</view>
							<input class="fs30 col10" v-model="item.name" placeholder="请输入位置"></input>
						</view>
					</template>

					<view class="pt50 pb30 m-hairline--bottom">
						<view class="fs30 col89 mb25">附近医疗数量</view>
						<input class="fs30 col10" v-model="nearby_hospital_num" placeholder="请输入"></input>
					</view>

					<template v-for="(item,index) in nearby_hospital_arr">
						<view class="pt50 pb30 m-hairline--bottom">
							<view class="fs30 col89 mb25">医疗站{{index+1}}</view>
							<input class="fs30 col10" v-model="item.name" placeholder="请输入位置"></input>
						</view>
					</template>


					<view class="pb30 m-hairline--bottom">
						<uni-forms-item name="content">
							<view class="fs30 col89 mb30">详情描述</view>
							<textarea :adjust-position="true" class="heading" v-model="current.content" style="height: 200rpx;"
								placeholder="请填写"></textarea>
						</uni-forms-item>
					</view>








				</view>
			</view>
		</uni-forms>


	</view>
</template>

<script>
	const core = require('@/xilu/core.js');
	const app = getApp();
	export default {
		data() {
			return {
        house_id :0,
				rental_id: 0,
				userinfo:{},
				village: [], //小区
				comment: [], //标签
				cus:{
					sale_state:[
						{
							id:1,
							name:'在售'
						},
						{
							id:2,
							name:'售罄'
						},
						{
							id:3,
							name:'待售'
						}
					],
					sale_state_index:0,
					is_low_price_protect:[
						{
							id:1,
							name:'无'
						},
						{
							id:2,
							name:'有'
						},
					],
					is_low_price_protect_index:0
				},


				rentalMode:[], //租赁模式,
				rentalModeIndex:0,
				houseType: [], //房源类型
				houseTypeIndex: -1,
				nearby_bus_num:'',
				nearby_subway_num:'',
				nearby_school_num:'',
				nearby_shop_num:'',
				nearby_hospital_num:'',


				nearby_bus_arr:[],
				nearby_subway_arr:[],
				nearby_school_arr:[],
				nearby_shop_arr:[],
				nearby_hospital_arr:[],

				houseDeveloper: [],
				houseDeveloperIndex: 0,
				houseHouseTag:[],
				defaultRegion: [],
				defaultRegionCode: '11',
				region: [],
				street: [],
				images:[],



				current: {
					"name": "",
					"sale_state": 1,
					"is_low_price_protect": 1,
					"alias_name":'',
					"price": "",
					"min_total_price": "",
					"max_total_price": "",
					"image": "",
					"vr_url": "",
					"build_image": "",
					"images": "",
					"prov": "",
					"city": "",
					"region": "",
					"street": "",
					"addr": "",
					"subway_distance": null,
					"subway_distance_text": null,
					"house_type_id": '',
					"house_developer_id": '',
					"room_num": '',
					"floor_num": '',
					"elevator_num": '',
					"stepLadder_num": '',
					"user_id": '',
					"house_tag_ids": '',
					"min_room_num":'',
					"max_room_num": '',
					"min_space": '',
					"max_space": '',
					"build_space": null,
					"opentime": '',
					"deliverytime": '',
					"content": "",
					"cosult_tel": "",
					"discounts": "",
					"first_price_msg": "",
					"hot_msg": "",
					"nearby_bus_num":'',
					"nearby_subway_num":'',
					"nearby_school_num":'',
					"nearby_shop_num":'',
					"nearby_hospital_num":'',

				},
				rules: {
					build_image: {
						rules: [{
							required: true,
							errorMessage: '请上传楼栋图片'
						}]
					},

					name: {
						rules: [{
							required: true,
							errorMessage: '请输入楼盘名称'
						}]
					},

					price: {
						rules: [{
							required: true,
							errorMessage: '请输入价格'
						}]
					},
					content: {
						rules: [{
							required: true,
							errorMessage: '请输入房间介绍'
						}]
					},

				},
			}
		},
		onReady: function() {
			this.$refs.form.setRules(this.rules)
		},
		onLoad(options) {
      let that = this;
      this.house_id = options.id || 0
      this.fetchHouseInfo()
			this.fetchUserInfo();
			this.fetchHouseType();
			this.fetchDeveloper();
			this.fetchHouseTag();

		},
		onUnload(){
			// uni.$off("chooseVillage");
		},
		computed: {
			regionName() {
				// 转为字符串
				return this.region.map(item => item.name).join(' ')
			}
		},
		watch: {
			nearby_bus_num: {
				handler(newVal, oldVal) {
					if(this.house_id){
						return
					}
				
					const temp = []
					for(let i = 0; i<newVal;i++){
						temp.push({'name':''})
					}
					this.nearby_bus_arr = temp
					
				},
				immediate: true,
			},
			nearby_subway_num: {
				handler(newVal, oldVal) {
					if(this.house_id){
						return
					}
					const temp = []
					for(let i = 0; i<newVal;i++){
						temp.push({'name':''})
					}
					this.nearby_subway_arr = temp
				},
				immediate: true,
			},
			nearby_school_num: {
				handler(newVal, oldVal) {
					if(this.house_id){
						return
					}
					const temp = []
					for(let i = 0; i<newVal;i++){
						temp.push({'name':''})
					}
					this.nearby_school_arr = temp
				},
				immediate: true,
			},
			nearby_shop_num: {
				handler(newVal, oldVal) {
					if(this.house_id){
						return
					}
					const temp = []
					for(let i = 0; i<newVal;i++){
						temp.push({'name':''})
					}
					this.nearby_shop_arr = temp
				},
				immediate: true,
			},
			nearby_hospital_num: {
				handler(newVal, oldVal) {
					if(this.house_id){
						return
					}
					const temp = []
					for(let i = 0; i<newVal;i++){
						temp.push({'name':''})
					}
					this.nearby_hospital_arr = temp
				},
				immediate: true,
			},
		},
		methods: {
			fmtUrl(url){
				if(!url){
					return ''
				}
				return  app.globalData.web_url+ url
			},
			fetchUserInfo(){
				let that = this;
				core.get({url:'/api/xiluhouse.user/index',data:{},success:(ret)=>{
					that.userinfo = ret.data;
				},loading:false});
			},
      fetchHouseInfo(){
        let that = this;
        if(!this.house_id){
          return
        }
        core.get({url:'/api/xiluhouse.broker/house_info',data:{id:this.house_id},success:(ret)=>{
            that.current = ret.data;
            that.region = []
            that.region.push({'name':ret.data.prov})
            that.region.push({'name':ret.data.city})
            that.region.push({'name':ret.data.region})

            that.images = ret.data.images
            that.current.opentime = ret.data.opentime_text;
            that.current.deliverytime = ret.data.deliverytime_text;
			that.nearby_bus_num =  ret.data.nearby_bus_num
			if(that.nearby_bus_num){
				that.nearby_bus_arr = JSON.parse(JSON.stringify(ret.data.nearby_bus_json))
			}
			
			that.nearby_hospital_num =  ret.data.nearby_hospital_num
			if(that.nearby_hospital_num){
				that.nearby_hospital_arr = JSON.parse(JSON.stringify(ret.data.nearby_hospital_json))
			}
			
			that.nearby_school_num =  ret.data.nearby_school_num
			if(that.nearby_school_num){
				that.nearby_school_arr = JSON.parse(JSON.stringify(ret.data.nearby_school_json))
			}
			that.nearby_shop_num=  ret.data.nearby_shop_num
			if(that.nearby_shop_num){
				that.nearby_shop_arr = JSON.parse(JSON.stringify(ret.data.nearby_shop_json))
			}
			that.nearby_subway_num =  ret.data.nearby_subway_num
			if(that.nearby_subway_num){
				that.nearby_subway_arr = JSON.parse(JSON.stringify(ret.data.nearby_subway_json))
			}
			this.$forceUpdate()
          },loading:false});
      },

			//选择房屋类型
			checkRentalMode(index) {
				this.rentalModeIndex = index;
				this.current.rental_mode_id = this.rentalMode[index].id
			},
			//获取房屋属性
			fetchHouseType() {
				let that = this;
				core.get({
					url: 'api/xiluhouse.common/house_type',
					success: ret => {
					
						that.houseType = ret.data;
						that.houseTypeIndex = 0
						if(that.houseType.length){
							that.current.house_type_id = that.houseType[0].id
						}

					}
				});
			},
			fetchDeveloper() {
				let that = this;
				core.get({
					url: 'api/xiluhouse.common/developer',
					success: ret => {
						that.houseDeveloper = ret.data;
						that.houseDeveloperIndex = 0
						if(that.houseDeveloper.length){
							that.current.house_developer_id = that.houseDeveloper[0].id
						}

					}
				});
			},
			fetchHouseTag() {
				let that = this;
				core.get({
					url: 'api/xiluhouse.common/house_tag',
					success: ret => {
						that.houseHouseTag = ret.data;

					}
				});
			},

			//选择房屋类型
			checkType(index) {
				this.houseTypeIndex = index;
				this.current.house_type_id = this.houseType[index].id
			},
			checkDeveloperType(index) {
				this.houseDeveloperIndex = index;
				this.current.house_developer_id = this.houseDeveloper[index].id
			},



			checkFmtType(index,key){
				this.cus[key+'_index'] = index
				this.current[key] = this.cus[key][index].id
			},
			//获取标签属性
			fetchTags() {
				let that = this;
				core.get({
					url: 'api/xiluhouse.common/rental_tags',
					data: {
						pageSize: 15
					},
					success: ret => {
						if(that.rental_id){
							let house_tag_ids = that.current.house_tag_ids ? that.current.house_tag_ids.split(','): [];
							if(house_tag_ids.length>0){
								for(let i=0;i<ret.data.length;i++){
									for(let j=0;j<ret.data[i].tags.length;j++){
										if(house_tag_ids.indexOf(ret.data[i].tags[j].id.toString()) !== -1){
											ret.data[i].tags[j].is_check = true;
										}
									}

								}
							}
						}
						this.comment = ret.data
					}
				});
			},
			//选择标签属性
			chooseTag( s_index) {
				let that = this;
				that.houseHouseTag[s_index].is_check = !that.houseHouseTag[s_index].is_check
				const ids = []
				for(const i in that.houseHouseTag){
					if(that.houseHouseTag[i].is_check){
						ids.push(that.houseHouseTag[i].id)
					}
				}
				that.current.house_tag_ids = ids.join(',')
				that.$forceUpdate();
			},
			//上传图片
			upload(type) {
				let that = this;
				let img = that.images
				let len = img.length;
				uni.chooseImage({
					count: 10 - len,
					success: res => {
						let files = res.tempFiles;
						files.map(item => {
							core.uploadFile({
								filePath: item.path,

								success: (ret, response) => {
									if (type == 1) {
										that.current.build_image = ret.data.url
									}else if (type == 2) {
										that.current.image = ret.data.url
									} else {
										img.push(ret.data.url)
										that.images = img;
									}
									this.$forceUpdate()
								}
							});
						});
					}
				});
			},
			// 获取选择的地区
			handleGetRegion(region) {
				this.region = region
				this.current.prov = region[0].name
				this.current.city = region[1].name
				this.current.region = region[2].name
				this.get_street(region[2].name)
			},
			//选择街道
			strChange(e) {
				let index = e.detail.value
				let street = this.street
				this.current.street = street[index].name
			},
			//获取街道
			get_street(name) {
				core.get({
					url: 'api/xiluhouse.universal/street_data',
					data: {
						region: name
					},
					success: ret => {
						this.street = ret.data
					}
				});
			},
			delImg(index) {
				let images = this.images
				images.splice(index, 1)
				this.images = images
			},
			//选择是否委托
			checkPublic(type) {
				this.current.is_public = type
			},

			decorationDatePicker(e) {
				this.current.opentime = e.detail.value
			},
			buildDatePicker(e) {
				this.current.deliverytime = e.detail.value
			},

			submit() {
				let that = this;
				that.$refs.form.validate(valid => {
					if (!valid) {
						let form = that.current;
            if (form.price <= 0) {
							uni.showToast({title: '请填写价格',icon: "none"})
							return false;
						}
						let images = that.images;
						if (!form.build_image) {
							uni.showToast({title: '请上传楼栋图片',icon: "none"})
							return false;
						}


						form['images'] = images.join(',');
						form['nearby_bus_json'] = JSON.stringify(that.nearby_bus_arr);
						form['nearby_subway_json'] = JSON.stringify(that.nearby_subway_arr);
						form['nearby_school_json'] = JSON.stringify(that.nearby_school_arr);
						form['nearby_shop_json'] = JSON.stringify(that.nearby_shop_arr);
						form['nearby_hospital_json'] = JSON.stringify(that.nearby_hospital_arr);




						core.post({
							url: 'api/xiluhouse.broker/add_house',
							data: form,
							loading:true,
							success: ret => {
								uni.showToast({
									title: ret.msg,
									icon: 'none',
									success:function (){
										uni.$emit("refreshRental",{})
										uni.navigateBack({
											delta: 1
										})
									}
								});
							}
						});
					} else {
						console.log('验证失败');
					}
				});
			},


		},

	}
</script>

<style scoped lang="less">
	.icon-search {
		padding: 5rpx;
		display: block;
		width: 40rpx;
		height: 40rpx;
	}


	.upload .item {
		position: relative;
		margin: 0 30rpx 30rpx 0;
		width: 200rpx;
		height: 156rpx;
		border-radius: 10rpx;
		overflow: hidden;
	}

	.upload .item:nth-of-type(3n) {
		margin: 0 0 30rpx;
	}

	.upload .item.btn {
		padding: 36rpx 0 0;
		background: #F7F9FC;
	}

	.upload .icon {
		margin: 0 auto 7rpx;
		display: block;
		width: 45rpx;
		height: 45rpx;
	}

	.upload .img {
		display: block;
		width: 200rpx;
		height: 156rpx;
	}

	.upload .icon-clear {
		position: absolute;
		right: 13rpx;
		top: 13rpx;
		display: block;
		width: 30rpx;
		height: 30rpx;
		z-index: 10;
	}


	.upload-box {
		position: relative;
		width: 750rpx;
		height: 500rpx;
		background: #F7F9FC;

		.icon-upload {
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			display: block;
			width: 183rpx;
			height: 140rpx;
			z-index: 1;
		}

		.img {
			position: absolute;
			top: 0;
			left: 0;
			display: block;
			width: 750rpx;
			height: 500rpx;
			z-index: 2;
		}
	}

	.heading {
		width: 690rpx;
		height: 88rpx;
		font-size: 30rpx;
		font-weight: 500;
		color: #101010;
		line-height: 44rpx;
	}

	.label-list {
		.label {
			position: relative;
			margin: 0 20rpx 20rpx 0;

			width: 150rpx;
			height: 66rpx;
			background: #F8F9FB;
			border-radius: 4rpx;
			border: 1px solid #EEEEEE;
			font-size: 26rpx;
			color: #333333;
			line-height: 66rpx;
			text-align: center;

			.icon-select {
				position: absolute;
				right: 0;
				bottom: -1rpx;
				display: none;
				width: 31rpx;
				height: 28rpx;
			}
		}

		.label:nth-of-type(4n) {
			margin: 0 0 20rpx;
		}

		.label.active {
			color: var(--normal);
			border: 1px solid var(--normal);

			.icon-select {
				display: block;
			}
		}
	}

	.page-foot {
		.foot-wrap {
			padding: 10rpx 60rpx;

			.foot-btn1 {
				width: 300rpx;
				height: 80rpx;
				border-radius: 40rpx;
				border: 1px solid var(--normal);
				font-size: 30rpx;
				color: var(--normal);
				line-height: 80rpx;
				text-align: center;
			}

			.foot-btn2 {
				width: 300rpx;
				height: 80rpx;
				border-radius: 40rpx;
				background: var(--normal);
				font-size: 30rpx;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
			}
		}
	}
</style>
